/*
 * 2017-12-26
 * 
 * */
var nf = sm("do_Notification");
var app = sm("do_App");
//组件列表
 var listdata = mm("do_ListData");
//定义listview界面
var listView = ui("do_ListView_member");
//绑定数据
listView.bindItems(listdata);
//需要Cell对应的模板UI文件组
listView.templates="source://view/member/cell.ui";
//调用initdata 组件，读取本地的json 数据
var initdata = sm("do_InitData");
var service_url = sm("do_Global");
var url  = service_url.getMemory("service_url");
var cacher = sm("do_DataCache");
getmembers();

//上下滑动，恢复headerview和footerview
listView.rebound();

listView.on("touch",function(index){
	app.openPage({
		source:"source://view/memberdetails/memberdetails.ui", 
		data:listdata.getOne(index)
		});
});

function getmembers(){
	var http = mm("do_Http");
	http.method = "GET";
	http.timeout = 30000;
	http.contentType = "application/json";
	http.setRequestHeader("X-Requested-With", "XMLHttpRequest");
	var token = cacher.loadData("token");
	http.setRequestHeader("Cookie", token+"");
	http.url = url+"index.php?s=/admin/member/memberlist";
	
	http.on("success", function(data) {
		//nf.toast(data);
		//将数据添加到组件中
		var re = http.getResponseHeader();
		deviceone.print(JSON.stringify(re));
		listdata.addData(data);
		listView.bindItems(listdata);
		listView.refreshItems();
		//app.openPage("source://view/index.ui");
	});
	http.request();
}


 